# -*- coding: utf-8 -*-

def ValueSearch(arr, key):
    left = 0
    right = len(arr) - 1
    while left < right:
        mid = left + int((right - left)*(key - arr[left]) / (arr[right] - arr[left]))
        if key < arr[mid]:
            right = mid - 1
        elif key > arr[mid]:
            left = mid + 1
        else:
            return mid
    return -1

s1 = [0,3,5,7,9,20,30,40,50]
key = 50
r = ValueSearch(s1, key)
if r == -1:
    print('%d没有找到' % (key))
else:
    print('查找值%d在列表里的下标值为%d' %(key, r))
